# This file is part of the 'dragora-installer'.
#
# Purpose: Show detected series from medium to be chosen.

MEDIUM_SOURCE="$(cat -- ${SUBTMPDIR}/MediumFound)"
export MEDIUM_SOURCE

cat << EOF > ${SUBTMPDIR}/ShowSeries
dialog --colors \\
 --backtitle "\ZbChoosing the series" \\
 --title "SOFTWARE SERIES" --no-cancel \\
 --item-help --checklist \\
"The following series of software were found for installation.\n\\
Use the cursor keys and the space bar to select the series\n\\
you want to install.  Finally, press \Zb\Z7ENTER\Zn to continue." 20 65 12 \\
EOF

if test -d "${MEDIUM_SOURCE}"/@ARCH@/boot
then
    echo '"boot" "" on "Necessary software to boot the system." \' \
     >> ${SUBTMPDIR}/ShowSeries
fi
if test -d "${MEDIUM_SOURCE}"/@ARCH@/compressors
then
    echo '"compressors" "" on "Several compressors at user-level." \' \
     >> ${SUBTMPDIR}/ShowSeries
fi
if test -d "${MEDIUM_SOURCE}"/@ARCH@/daemons
then
    echo '"daemons" "" on "System-related daemons." \' \
     >> ${SUBTMPDIR}/ShowSeries
fi
if test -d "${MEDIUM_SOURCE}"/@ARCH@/data
then
    echo '"data" "" on "Essential configuration files." \' \
     >> ${SUBTMPDIR}/ShowSeries
fi
if test -d "${MEDIUM_SOURCE}"/@ARCH@/db
then
    echo '"db" "" on "Databases: berkeley-db, gdbm, tzdb." \' \
     >> ${SUBTMPDIR}/ShowSeries
fi
if test -d "${MEDIUM_SOURCE}"/@ARCH@/devel
then
    echo '"devel" "" on "Compilers, programming languages, and debuggers." \' \
     >> ${SUBTMPDIR}/ShowSeries
fi
if test -d "${MEDIUM_SOURCE}"/@ARCH@/dict
then
    echo '"dict" "" on "Spell checker and dictionaries." \' \
     >> ${SUBTMPDIR}/ShowSeries
fi
if test -d "${MEDIUM_SOURCE}"/@ARCH@/docbook
then
    echo '"docbook" "" on "SGML and XML support for DocBook documents." \' \
     >> ${SUBTMPDIR}/ShowSeries
fi
if test -d "${MEDIUM_SOURCE}"/@ARCH@/gnupg
then
    echo '"gnupg" "" on "The GNU privacy guard." \' \
     >> ${SUBTMPDIR}/ShowSeries
fi
if test -d "${MEDIUM_SOURCE}"/@ARCH@/kernel
then
    echo '"kernel" "" on "The Linux-libre kernel: images, headers, and modules." \' \
     >> ${SUBTMPDIR}/ShowSeries
fi
if test -d "${MEDIUM_SOURCE}"/@ARCH@/libs
then
    echo '"libs" "" on "System libraries." \' \
     >> ${SUBTMPDIR}/ShowSeries
fi
if test -d "${MEDIUM_SOURCE}"/@ARCH@/networking
then
    echo '"networking" "" on "Clients and servers for networking." \' \
     >> ${SUBTMPDIR}/ShowSeries
fi
if test -d "${MEDIUM_SOURCE}"/@ARCH@/perl
then
    echo '"perl" "" on "Perl programming language plus modules." \' \
     >> ${SUBTMPDIR}/ShowSeries
fi
if test -d "${MEDIUM_SOURCE}"/@ARCH@/python
then
    echo '"python" "" on "Python programming language Python plus modules." \' \
     >> ${SUBTMPDIR}/ShowSeries
fi
if test -d "${MEDIUM_SOURCE}"/@ARCH@/ruby
then
    echo '"ruby" "" on "Ruby programming language plus modules." \' \
     >> ${SUBTMPDIR}/ShowSeries
fi
if test -d "${MEDIUM_SOURCE}"/@ARCH@/shells
then
    echo '"shells" "" on "Command interpreters." \' \
     >> ${SUBTMPDIR}/ShowSeries
fi
if test -d "${MEDIUM_SOURCE}"/@ARCH@/tools
then
    echo '"tools" "" on "Tools and complements of the base system." \' \
     >> ${SUBTMPDIR}/ShowSeries
fi
if test -d "${MEDIUM_SOURCE}"/@ARCH@/xorg
then
    echo '"xorg" "" on "The X Window System." \' \
     >> ${SUBTMPDIR}/ShowSeries
fi
if test -d "${MEDIUM_SOURCE}"/@ARCH@/x-apps
then
    echo '"x-apps" "" on "A collection of applications for the X Window System." \' \
     >> ${SUBTMPDIR}/ShowSeries
fi
if test -d "${MEDIUM_SOURCE}"/@ARCH@/x-libs
then
    echo '"x-libs" "" on "A collection of libraries for the X Window System." \' \
     >> ${SUBTMPDIR}/ShowSeries
fi
if test -d "${MEDIUM_SOURCE}"/@ARCH@/xfce
then
    echo '"xfce" "" on "Xfce is a lightweight desktop environment." \' \
     >> ${SUBTMPDIR}/ShowSeries
fi

# Check if there are any detected series
if test ! -f ${SUBTMPDIR}/ShowSeries || test ! -s ${SUBTMPDIR}/ShowSeries
then
    echo "${PROGRAM}: Error no series was detected.  Aborting..." 1>&2
    exit 99;
fi
echo ' 2> ${SUBTMPDIR}/return-ShowSeries' >> ${SUBTMPDIR}/ShowSeries

touch ${SUBTMPDIR}/return-ShowSeries

. ${SUBTMPDIR}/ShowSeries;	# Show menu.

if test ! -f ${SUBTMPDIR}/return-ShowSeries || test ! -s ${SUBTMPDIR}/return-ShowSeries
then
    echo "${PROGRAM}: Error no series was selected.  Aborting..." 1>&2
    exit 99;
fi

# Append a new line for reading (this will be done from 'InstallPackages')
echo "" >> ${SUBTMPDIR}/return-ShowSeries

